#include <bits/stdc++.h>

using namespace std;

int n,a,b;
int f[210];
int ans=0x7ffffff;
int vis[210];

void dfs(int now,int times)
{
    if(times>n)
        return;
    if(now==b)
    {
        ans = min(ans,times);

    }
    else if(times<=ans)
    {
        vis[now] = 1;
        if(now-f[now]>=1&&!vis[now-f[now]])
        {
           // vis[now-f[now]] = 1;
            dfs(now-f[now],times+1);
           // vis[now-f[now]]=0;
        }
        if(now+f[now]<=n&&!vis[now+f[now]])
        {
            //vis[now+f[now]] = 1;
            dfs(now+f[now],times+1);
            //vis[now-f[now]] = 0;
        }
        vis[now] = 0;
    }


}
int main()
{
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++)
    {
        cin>>f[i];
    }
    vis[a] = 1;
    dfs(a,0);
    if(ans!=0x7ffffff)
        cout<<ans;
    else
        cout<<-1;
    return 0;
}